package com.jinyu.admin.service.sys.impl;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.IdUtil;
import com.jinyu.admin.service.sys.SysDictDataService;
import com.jinyu.dao.entity.sys.SysDictData;
import com.jinyu.dao.mapper.sys.SysDictDataMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: yangli
 * @Despriction:
 * @Package: com.jinyu.admin.service.sys.impl
 * @Date:Created in 2022/5/6 23:14
 * @Modify By:
 */
@Service
public class SysDictDataServiceImpl implements SysDictDataService {

    @Autowired
    private SysDictDataMapper sysDictDataMapper;

    @Override
    public int insert(SysDictData sysDictData) {
        StpUtil.checkLogin();
        String loginId = StpUtil.getLoginIdAsString();
        sysDictData.setId(IdUtil.getSnowflakeNextId());
        sysDictData.setCreateUser(loginId);
        sysDictData.setUpdateUser(loginId);
        return sysDictDataMapper.insert(sysDictData);
    }

    @Override
    public int delete(long id) {
        return sysDictDataMapper.delete(id);
    }

    @Override
    public int update(SysDictData sysDictData) {
        return sysDictDataMapper.update(sysDictData);
    }

    @Override
    public SysDictData selectByOne(long id) {
        return sysDictDataMapper.selectByOne(id);
    }

    @Override
    public List<SysDictData> pageList(int offset, int pagesize) {
        return sysDictDataMapper.pageList(offset,pagesize);
    }
}
